package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.itheima.domain.Student;
import com.itheima.mapper.StudentMapper;
import com.itheima.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    public List<Student> findAll() {
        LambdaQueryWrapper<Student> wrapper = new LambdaQueryWrapper<Student>();
        return studentMapper.selectList(wrapper);
    }

    public void save(Student student) {
        studentMapper.insert(student);
    }

    public Student findByNumber(String number) {
        return studentMapper.selectById(number);
    }

    public void update(Student student) {
        studentMapper.updateById(student);
    }

    public void deleteByNumber(String number) {
        studentMapper.deleteById(number);
    }
}
